#!user/bin/env python3
# -- coding: utf-8 --
import time
from selenium.webdriver.edge.service import Service
from selenium.webdriver.common.by import By
from selenium import webdriver

drive = webdriver.Edge(service=Service(r'C:\Users\Administrator\PycharmProjects\web_crawler\MicrosoftWebDriver.exe'))
drive.get('https://www.baidu.com/')
drive.minimize_window()
# 八大定位方法定位百度网页
# find_element_by_name	name定位
# find_element_by_id	根据id属性值获取元素列表
# find_element_by_xpath	返回一个包含元素的列表
# find_element_by_link_text	根据标签的文本获取元素列表，精确定位
# find_element_by_partial_link_text	根据标签包含的文本获取元素列表，模糊定位
# find_element_by_tag_name	根据标签名获取元素列表
# find_element_by_class_name	根据类名获取元素列表
# find_element_by_css_selector	CSS定位

# input_ele = drive.find_element(By.NAME, 'wd')
# input_ele = drive.find_element(By.ID, 'kw')
# input_ele = drive.find_element(By.XPATH, '//*[@id="kw"]')
# input_ele = drive.find_element(By.LINK_TEXT, '网盘')
# input_ele = drive.find_elements(By.PARTIAL_LINK_TEXT, '百度')
# baidu = [baidu.text for baidu in input_ele]
# input_ele = drive.find_elements(By.TAG_NAME, 'input')
# input_ele = drive.find_element(By.CLASS_NAME, 's-hotsearch-content')
input_ele = drive.find_element(By.CSS_SELECTOR, '#su')
print(input_ele)
time.sleep(2)
drive.close()
